/***************************************************************************
 创建者: 华磊
 开始时间: 2019.11.20
 copyright: (C) 华友高科
 ***************************************************************************/
#include "weldstartinstructionlogic.h"
#include "GeneralDefine.h"
#include "programengine.h"
#include "messagelog.h"
#define D_WELD_WAIT_SLEEP 0.001 //S

WeldStartInstructionLogic::WeldStartInstructionLogic(QString configFilePathIn, int robotIdIn,
             ProgramSet *programSetIn, RobotIo *ioControllerIn, ProgramEngine *programEngineIn)
{
    programSet=programSetIn;
    robotId=robotIdIn;
    ioController=ioControllerIn;
    programEngine=programEngineIn;
    configFilePath=configFilePathIn;
    isVirtualControl=false;
    isInWelding=false;
    isUseArcWeldModule=false;

    weldSystemInfofilePath=D_TCRCONTROLLER_DATA_PATH;
    weldSystemInfofilePath += ROBOT_COMMON_NAME + QString::number(robotId)
            + "/config/InstructionConfig/weldSystem.xml";

    #ifndef D_USE_ROS
    //获取焊接XML配置文件信息
    QString readComent;
    int tmpReturn = readConfigFile(configFilePathIn,readComent);
    if(1!=tmpReturn)
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12500, robotId ,0,0,0,0,readComent);
    }

    tmpReturn = readWeldSystemInfo(weldSystemInfofilePath,weldSystemInfomation,isUseArcWeldModule,readComent);
    if(1!=tmpReturn)
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12501, robotId ,0,0,0,0,readComent);
    }
    #endif


}

E_PROGRAM_LOOP_RESULT WeldStartInstructionLogic::startWeldStart(int programNum,
                                                 WeldStartInstruction weldStartInstruct)
{
    qDebug()<<"startWeldStart";
    if(isVirtualControl)
    {
        qDebug()<<"virtual weld~";
        programEngine->calculateNextLineToRun(programNum);

        return programEngine->isTheLastInstruction(programNum);
    }
    if(false==isUseArcWeldModule)
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12507, robotId );
        return E_PROGRAM_LOOP_RESULT_ERROR;
    }

    double tmpWeldVoltage1,tmpWeldVoltage2;
    double tmpWeldAmp1,tmpWeldAmp2;

    WeldProperty tmpWeldProperty;
    if(1!=getWeldPropertyWithIndex(weldStartInstruct.weldPropertyIndex,tmpWeldProperty))
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12506, robotId );
        return E_PROGRAM_LOOP_RESULT_ERROR;
    }

    switch(weldStartInstruct.weldType)
    {
    case E_WELD_TYPE_COMMON:
    {
        WeldCondition tmpWeldCondition;
        if(1!=getWeldConditionInfoWithIndex(weldStartInstruct.weldConditionIndex,tmpWeldCondition))
        {
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12505, robotId );
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }
        tmpWeldVoltage1=tmpWeldCondition.weldStartVoltage;
        tmpWeldAmp1=tmpWeldCondition.weldStartAmp;
        tmpWeldVoltage2=tmpWeldCondition.voltage;
        tmpWeldAmp2=tmpWeldCondition.amp;
        break;
    }
    case E_WELD_TYPE_AMP:
    {
        tmpWeldVoltage1=weldStartInstruct.weldVoltage;
        tmpWeldAmp1=weldStartInstruct.weldAmp;
        tmpWeldVoltage2=weldStartInstruct.weldVoltage;
        tmpWeldAmp2=weldStartInstruct.weldAmp;
        break;
    }
    case E_WELD_TYPE_SPEED:
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12504, robotId );
        return E_PROGRAM_LOOP_RESULT_ERROR;
        break;
    }
    default:
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12504, robotId );
        return E_PROGRAM_LOOP_RESULT_ERROR;
        break;
    }
    }

    //开始起弧逻辑控制
    //开气／给电流电压
    ioController->setDo(do_gas_detection, true);
    ioController->setAo(ao_weld_voltage, getAoByVoltageCommand(tmpWeldVoltage1));//给定电压
    ioController->setAo(ao_weld_Amp, getAoByAmpCommand(tmpWeldAmp1));//给定电流
    //等预送气时间
    usleep(tmpWeldProperty.prePlenum*1000000.0);
    //开电弧
    ioController->setDo(do_weld_start, true);
    //等起弧成功
    int waitCount=0;
    while (false==ioController->getDi(di_weld_startSucceful))
    {
        waitCount++;
        usleep(D_WELD_WAIT_SLEEP*1000000.0);//weldSystemInfomation.arcStartDetectTime
        if(waitCount*D_WELD_WAIT_SLEEP>weldSystemInfomation.arcStartMaxWaitTime)
        {
            stopWeld();
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12502, robotId );
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }
    }
    //启动延迟等待
    qDebug()<<"焊接启动延迟等待时间"<<tmpWeldProperty.arcStartingTime;
    if(tmpWeldProperty.arcStartingTime>0.00001)
    {
      usleep(tmpWeldProperty.arcStartingTime*1000000.0);
    }
    qDebug()<<"结束延迟等待时间";

    //设定工作电压电流
    ioController->setAo(ao_weld_voltage, getAoByVoltageCommand(tmpWeldVoltage2));//给定电压
    ioController->setAo(ao_weld_Amp, getAoByAmpCommand(tmpWeldAmp2));//给定电流


    isInWelding=true;
    programEngine->calculateNextLineToRun(programNum);

    return programEngine->isTheLastInstruction(programNum);
}

E_PROGRAM_LOOP_RESULT WeldStartInstructionLogic::startWeldEnd(int programNum, WeldEndInstruction weldEndInstruct)
{
    qDebug()<<"startWeldEnd";
    isInWelding=false;
    if(isVirtualControl)
    {
        qDebug()<<"virtual weld~";
        programEngine->calculateNextLineToRun(programNum);

        return programEngine->isTheLastInstruction(programNum);

    }
    if(false==isUseArcWeldModule)
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12507, robotId );
        return E_PROGRAM_LOOP_RESULT_ERROR;
    }
    double tmpWeldVoltage1,tmpWeldVoltage2;
    double tmpWeldAmp1,tmpWeldAmp2;

    WeldProperty tmpWeldProperty;
    if(1!=getWeldPropertyWithIndex(weldEndInstruct.weldPropertyIndex,tmpWeldProperty))
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12506, robotId );
        return E_PROGRAM_LOOP_RESULT_ERROR;
    }

    switch(weldEndInstruct.weldType)
    {
    case E_WELD_TYPE_COMMON:
    {
        WeldCondition tmpWeldCondition;
        if(1!=getWeldConditionInfoWithIndex(weldEndInstruct.weldConditionIndex,tmpWeldCondition))
        {
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12505, robotId );
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }
        tmpWeldVoltage1=tmpWeldCondition.weldEndVoltage;
        tmpWeldAmp1=tmpWeldCondition.weldEndAmp;
        break;
    }
    case E_WELD_TYPE_AMP:
    {
        tmpWeldVoltage1=weldEndInstruct.weldVoltage;
        tmpWeldAmp1=weldEndInstruct.weldAmp;

        break;
    }
    default:
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12504, robotId );
        return E_PROGRAM_LOOP_RESULT_ERROR;
        break;
    }
    }

    //开始收弧逻辑控制
    //给电流电压
    ioController->setAo(ao_weld_voltage, getAoByVoltageCommand(tmpWeldVoltage1));//给定电压
    ioController->setAo(ao_weld_Amp, getAoByAmpCommand(tmpWeldAmp1));//给定电流

    //后处理时间等待
    if(tmpWeldProperty.arcExtinguishingTime>0.00001)
    {
        usleep(tmpWeldProperty.arcExtinguishingTime*1000000.0);
    }


    //关电弧
    ioController->setDo(do_weld_start, false);

    //送气延迟等待
    usleep(tmpWeldProperty.lagPlenum*1000000.0);

    //关气
    ioController->setDo(do_gas_detection, false);



    programEngine->calculateNextLineToRun(programNum);

    return programEngine->isTheLastInstruction(programNum);
}

int WeldStartInstructionLogic::getWeldDebugStatusInfo(WeldCraftStatusInfo &infoOut)
{
    infoOut.collisionStatus=ioController->getDi(di_collision);
    infoOut.isVirtualControl=isVirtualControl;
    infoOut.enableCollisionCheckStatus=enable_collision_check;
    infoOut.weldSucess=ioController->getDi(di_weld_startSucceful);
    infoOut.jogFeedStatus=0;
    infoOut.weldVoltage=getVoltageFeedback();
    infoOut.weldCurrency=getAmpFeedback();
    infoOut.weldTime=0;
    infoOut.weldPwm=0;
    return 1;
}

int WeldStartInstructionLogic::weldDebugOperation(E_WELD_TEST typeIn, bool control)
{
    switch(typeIn)
    {
    case E_WELD_TEST_FEEDWIRE:
        ioController->setDo(do_positive_wirefeeding,control);
        break;
    case E_WELD_TEST_WITHDRAWWIRE:
        ioController->setDo(do_reverse_wirefeeding,control);
        break;
    case E_WELD_TEST_GAS:
        ioController->setDo(do_gas_detection,control);
        break;
    }
    return 1;
}

int WeldStartInstructionLogic::weldWorkingMonitor()
{
    if(false==isUseArcWeldModule)
    {
        return 0;
    }

    bool isOk=true;
    if(isInWelding)
    {
        //检测起弧信号
        if(false==ioController->getDi(di_weld_startSucceful) && isInWelding)
        {
                //arcEndDelayAlarmTime todo 延迟检测逻辑
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12503, robotId );
                isOk=false;
        }
        //检测气体
    }
    if(false==isOk)
    {
        stopWeld();
        return -1;
    }

    //碰撞信号检测
    if(enable_collision_check )
    {

        if(collision_normal_logic!=ioController->getDi(di_collision))
        {
                //arcEndDelayAlarmTime todo 延迟检测逻辑
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "WeldStartInstructionLogic",  12508, robotId);
                if(isInWelding)
                {
                    stopWeld();
                }
                return -1;
        }
    }


    return 1;

}

int WeldStartInstructionLogic::stopWeld()
{
    if(isUseArcWeldModule)
    {
        ioController->setDo(do_weld_start, false);
        ioController->setDo(do_gas_detection, false);
        ioController->setDo(do_reverse_wirefeeding, false);
        ioController->setDo(do_positive_wirefeeding, false);
    }

    isInWelding=false;
    return 1;
}

bool WeldStartInstructionLogic::isInWeldingStatus()
{
    return isInWelding;
}

int WeldStartInstructionLogic::setWeldCollisionCheck(bool isCheck)
{
    enable_collision_check=isCheck;
    return 1;
}

int WeldStartInstructionLogic::setVirtualMode(bool isVirtualControlIn)
{
    isVirtualControl=isVirtualControlIn;
    return 1;
}

bool WeldStartInstructionLogic::getWeldIsVirtualStatus()
{
    return isVirtualControl;
}

int WeldStartInstructionLogic::getWeldConditionInfoWithIndex(int index,struct WeldCondition &weldCondition)
{
    usingMutex.lock();
    for(int i=0;i<weldConditionList.size();i++)
    {
        if(weldConditionList[i].index==index)
        {
            weldCondition=weldConditionList[i];
            usingMutex.unlock();
            return 1;
        }
    }
    usingMutex.unlock();
    return 0;

}

int WeldStartInstructionLogic::getWeldPropertyWithIndex(int index, WeldProperty &weldPropertyOut)
{
    usingMutex.lock();
    for(int i=0;i<weldPropertyList.size();i++)
    {
        if(weldPropertyList[i].index==index)
        {
            weldPropertyOut=weldPropertyList[i];
            usingMutex.unlock();
            return 1;
        }
    }
    usingMutex.unlock();
    return 0;
}

double WeldStartInstructionLogic::getVoltageFeedback()
{
    double tmpAi=ioController->getAi(ai_weld_voltageMes);
    return getVoltageFeedbackByAi(tmpAi);
}

double WeldStartInstructionLogic::getAmpFeedback()
{
    double tmpAi=ioController->getAi(ai_weld_IrealMes);
    return getAmpFeedbackByAi(tmpAi);
}

double WeldStartInstructionLogic::getVoltageFeedbackByAi(double ai)
{
    return minimum_ai_weld_voltageMes+ai*ratio_ai_weld_voltageMes;
}

double WeldStartInstructionLogic::getAmpFeedbackByAi(double ai)
{
    return minimum_ai_weld_IrealMes+ai*ratio_ai_weld_IrealMes;
}

double WeldStartInstructionLogic::getAoByVoltageCommand(double voltageCommand)
{
    return (voltageCommand-minimum_ao_weld_voltage)*ratio_ao_weld_voltage;//ao输出０ｖ时，设定电压１２ｖ
}

double WeldStartInstructionLogic::getAoByAmpCommand(double ampCommand)
{
    return (ampCommand-minimum_ao_weld_Amp)*ratio_ao_weld_Amp;//ao输出０ｖ时，设定电流３０ａ
}

int WeldStartInstructionLogic::getWeldCondition(std::vector<WeldCondition> &configListOut)
{
    usingMutex.lock();
    configListOut=weldConditionList;
    usingMutex.unlock();
    return 1;
}

int WeldStartInstructionLogic::changeWeldConditionConfig(struct WeldCondition weldCondition)
{
    usingMutex.lock();
    for(int i=0;i<weldConditionList.size();i++)
    {
        if(weldConditionList[i].index==weldCondition.index)
        {
            weldConditionList[i]=weldCondition;
            usingMutex.unlock();
            return writeWeldConditionConfig(configFilePath,weldCondition);
        }
    }
    usingMutex.unlock();
    return 0;
}

int WeldStartInstructionLogic::getWeldProperty(std::vector<WeldProperty> &configListOut)
{
    usingMutex.lock();
    configListOut=weldPropertyList;
    usingMutex.unlock();
    return 1;
}

int WeldStartInstructionLogic::changeWeldPropertConfig(struct WeldProperty weldProperty)
{
    usingMutex.lock();
    for(int i=0;i<weldPropertyList.size();i++)
    {
        if(weldPropertyList[i].index==weldProperty.index)
        {
            weldPropertyList[i]=weldProperty;
            usingMutex.unlock();
            return writeWeldPropertConfig(configFilePath,weldProperty);
        }
    }
    usingMutex.unlock();
    return 0;
}

int WeldStartInstructionLogic::getWeldSystemInfo(struct WeldSystemInfo &weldSystemInfo)
{
    weldSystemInfo=weldSystemInfomation;
    return 1;
}
int WeldStartInstructionLogic::changeWeldSystemInfo(struct WeldSystemInfo configIn)
{
    weldSystemInfomation=configIn;
    return writeWeldSystemInfo(weldSystemInfofilePath,configIn);

}

int WeldStartInstructionLogic::readWeldProperty(QString filePathIn,std::vector<WeldProperty> &configListOut, QString &readComent)
{
    qDebug() << "开始获取焊接属性文件列表信息";
    DomParser domparser;
    bool ok = domparser.openXml(filePathIn, QIODevice::ReadOnly);
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 配置文件打开失败：" << configFilePath;
        return -1;
    }

    QDomNode domNode_f = domparser.findSubNode(domparser.getRootDomElement(), "attributeConfig", ok );
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 读取attributeConfig结点失败：" << configFilePath;
        return -2;
    }

    QDomNodeList itemList = domNode_f.childNodes();

    for(int i=0;i<itemList.count();i++){
        struct WeldProperty weldProperty;
        // 读取并赋值
        domparser.readXml(domparser.findSubNode(itemList.at(i), "index", ok ), weldProperty.index);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "wealdEquipment", ok ), weldProperty.wealdEquipment);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "equipmentVendors", ok ), weldProperty.equipmentVendors);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "modelName", ok ), weldProperty.modelName);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "fileName", ok ), weldProperty.fileName);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "setingNum", ok ), weldProperty.setingNum);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "startTheProcess", ok ), weldProperty.startTheProcess);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "postProcessing", ok ), weldProperty.postProcessing);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "solubleApplyRemove", ok ), weldProperty.solubleApplyRemove);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "wealdTilt", ok ), weldProperty.wealdTilt);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "gasCleaning", ok ), weldProperty.gasCleaning);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "prePlenum", ok ), weldProperty.prePlenum);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "arcStartingTime", ok ), weldProperty.arcStartingTime);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "lagPlenum", ok ), weldProperty.lagPlenum);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "arcExtinguishingTime", ok ), weldProperty.arcExtinguishingTime);
        if( !ok )
        {
            return -2;
        }

        configListOut.push_back(weldProperty);
    }

    qDebug() << "获取list个数：" << itemList.count();

    domparser.closeXml();
    return 1;
}

int WeldStartInstructionLogic::writeWeldPropertConfig(QString filePathIn,WeldProperty weldProperty)
{
    qDebug() << "开始修改XML焊接属性的值";

    DomParser domparser;
    bool ok = domparser.openXml(filePathIn, QIODevice::ReadWrite);
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 配置文件打开失败：" << configFilePath;
        return -1;
    }

    QDomNode domNode_f = domparser.findSubNode(domparser.getRootDomElement(), "attributeConfig", ok );
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 读取attributeConfig结点失败：" << configFilePath;
        return -2;
    }

    QDomNodeList itemList = domNode_f.childNodes();

    for(int i=0;i<itemList.count();i++){
        if(weldProperty.index==i){
            domparser.writeXml(domparser.findSubNode(itemList.at(i), "index", ok ), weldProperty.index);
            if( !ok )
            {
                return -2;
            }

            QString str1 = QString("%1").arg(weldProperty.wealdEquipment.data());
            domparser.writeXml(domparser.findSubNode(itemList.at(i), "wealdEquipment", ok ),str1.size()==0 ? "暂无":str1);
            if( !ok )
            {
                return -2;
            }

            QString str2 = QString("%1").arg(weldProperty.equipmentVendors.data());
            domparser.writeXml(domparser.findSubNode(itemList.at(i), "equipmentVendors", ok ),str2.size()==0 ? "暂无":str2 );
            if( !ok )
            {
                return -2;
            }

            QString str3 = QString("%1").arg(weldProperty.modelName.data());
            domparser.writeXml(domparser.findSubNode(itemList.at(i), "modelName", ok ), str3.size()==0? "暂无":str3 );
            if( !ok )
            {
                return -2;
            }

            QString str4 = QString("%1").arg(weldProperty.fileName.data());
            domparser.writeXml(domparser.findSubNode(itemList.at(i), "fileName", ok ), str4.size()==0? "暂无":str4);
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "setingNum", ok ), QString("%1").arg(weldProperty.setingNum));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "startTheProcess", ok ), QString("%1").arg(weldProperty.startTheProcess));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "postProcessing", ok ),QString("%1").arg( weldProperty.postProcessing));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "solubleApplyRemove", ok ), QString("%1").arg(weldProperty.solubleApplyRemove));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "wealdTilt", ok ), QString("%1").arg(weldProperty.wealdTilt));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "gasCleaning", ok ), weldProperty.gasCleaning);
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "prePlenum", ok ), weldProperty.prePlenum);
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "arcStartingTime", ok ), weldProperty.arcStartingTime);
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "lagPlenum", ok ), weldProperty.lagPlenum);
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "arcExtinguishingTime", ok ), weldProperty.arcExtinguishingTime);
            if( !ok )
            {
                return -2;
            }
        }
    }

    domparser.closeXml(true);
    return 1;
}

int WeldStartInstructionLogic::readWeldCondition(QString filePathIn, std::vector<WeldCondition> &configListOut,
                                                 QString &readComent)
{
    qDebug() << "开始获取焊接条件文件列表信息";
    DomParser domparser;
    bool ok = domparser.openXml(filePathIn, QIODevice::ReadOnly);
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 配置文件打开失败：" << configFilePath;
        return -1;
    }

    QDomNode domNode_f = domparser.findSubNode(domparser.getRootDomElement(), "conditionsConfig", ok );
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 读取conditionsConfig结点失败：" << configFilePath;
        return -2;
    }

    QDomNodeList itemList = domNode_f.childNodes();

    for(int i=0;i<itemList.count();i++){
        struct WeldCondition weldCondition;
        // 读取并赋值
        domparser.readXml(domparser.findSubNode(itemList.at(i), "index", ok ), weldCondition.index);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "voltage", ok ), weldCondition.voltage);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "amp", ok ), weldCondition.amp);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "weldStartVoltage", ok ), weldCondition.weldStartVoltage);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "weldStartAmp", ok ), weldCondition.weldStartAmp);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "weldEndVoltage", ok ), weldCondition.weldEndVoltage);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "weldEndAmp", ok ), weldCondition.weldEndAmp);
        if( !ok )
        {
            return -2;
        }


        domparser.readXml(domparser.findSubNode(itemList.at(i), "speed", ok ), weldCondition.speed);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "weldSpeed", ok ), weldCondition.weldSpeed);
        if( !ok )
        {
            return -2;
        }

        domparser.readXml(domparser.findSubNode(itemList.at(i), "dealwithTime", ok ), weldCondition.dealwithTime);
        if( !ok )
        {
            return -2;
        }

        configListOut.push_back(weldCondition);
    }

    qDebug() << "获取list个数：" << itemList.count();

    domparser.closeXml();

    return 1;
}

int WeldStartInstructionLogic::writeWeldConditionConfig(QString filePathIn,WeldCondition weldCondition)
{
    qDebug() << "开始修改焊接条件文件列表信息";

    DomParser domparser;
    bool ok = domparser.openXml(filePathIn, QIODevice::ReadWrite);
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 配置文件打开失败：" << configFilePath;
        return -1;
    }

    QDomNode domNode_f = domparser.findSubNode(domparser.getRootDomElement(), "conditionsConfig", ok );
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 读取conditionsConfig结点失败：" << configFilePath;
        return -2;
    }

    QDomNodeList itemList = domNode_f.childNodes();

    for(int i=0;i<itemList.count();i++){
        if(weldCondition.index==i){
            domparser.writeXml(domparser.findSubNode(itemList.at(i), "index", ok ), weldCondition.index);
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "voltage", ok ), QString("%1").arg(weldCondition.voltage));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "amp", ok ), QString("%1").arg(weldCondition.amp));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "weldStartVoltage", ok ), QString("%1").arg(weldCondition.weldStartVoltage));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "weldStartAmp", ok ), QString("%1").arg(weldCondition.weldStartAmp));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "weldEndVoltage", ok ), QString("%1").arg(weldCondition.weldEndVoltage));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "weldEndAmp", ok ), QString("%1").arg(weldCondition.weldEndAmp));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "speed", ok ), QString("%1").arg(weldCondition.speed));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "weldSpeed", ok ), QString("%1").arg(weldCondition.weldSpeed));
            if( !ok )
            {
                return -2;
            }

            domparser.writeXml(domparser.findSubNode(itemList.at(i), "dealwithTime", ok ), QString("%1").arg(weldCondition.dealwithTime));
            if( !ok )
            {
                return -2;
            }
        }
    }

    domparser.closeXml(true);

    return 1;
}

int WeldStartInstructionLogic::readDiDoSetting(QString filePathIn, QString &readComent)
{
    qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 初始化配置文件：" << filePathIn;

    DomParser domparser;
    bool ok = domparser.openXml(filePathIn, QIODevice::ReadOnly);
    if( !ok )
    {
        qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 配置文件打开失败：" << filePathIn;
        return -1;
    }

    QDomNode domNode_f = domparser.findSubNode(domparser.getRootDomElement(), "didosetting", ok );
    if( !ok )
    {
        qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取didosetting结点失败：" << filePathIn;
        return -2;
    }

    QDomNode domNode = domparser.findSubNode(domNode_f, "do_weld_start", ok );
    if( !ok )
    {
        qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取do_weld_start结点失败：" << filePathIn;
        return -2;
    }
    //起弧信号
    domparser.readXml(domNode, do_weld_start);

    domNode = domparser.findSubNode(domNode_f, "do_reverse_wirefeeding", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取agv_rotateMaxAcceleration结点失败：" << filePathIn;
         return -2;
    }
    //反向送丝信号
    domparser.readXml(domNode, do_reverse_wirefeeding);

    domNode = domparser.findSubNode(domNode_f, "di_weld_startSucceful", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取di_weld_startSucceful结点失败：" << filePathIn;
         return -2;
    }
    //起弧成功信号
    domparser.readXml(domNode, di_weld_startSucceful);

    domNode = domparser.findSubNode(domNode_f, "ai_weld_IrealMes", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取ai_weld_IrealMes结点失败：" << filePathIn;
         return -2;
    }
    //焊接电流信号（反馈）
    domparser.readXml(domNode, ai_weld_IrealMes);

    domNode = domparser.findSubNode(domNode_f, "do_positive_wirefeeding", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取do_positive_wirefeeding结点失败：" << filePathIn;
         return -2;
    }
    //正向送丝信号
    domparser.readXml(domNode, do_positive_wirefeeding);

    domNode = domparser.findSubNode(domNode_f, "do_gas_detection", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取do_gas_detection结点失败：" << filePathIn;
         return -2;
    }
    //气体检测信号
    domparser.readXml(domNode, do_gas_detection);

    domNode = domparser.findSubNode(domNode_f, "di_find_position", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取di_find_position结点失败：" << filePathIn;
         return -2;
    }
    //机器人寻位信号
    domparser.readXml(domNode, di_find_position);

    domNode = domparser.findSubNode(domNode_f, "ao_weld_voltage", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取ao_weld_voltage结点失败：" << filePathIn;
         return -2;
    }
    //给定电压信号
    domparser.readXml(domNode, ao_weld_voltage);

    domNode = domparser.findSubNode(domNode_f, "ao_weld_Amp", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取ao_weld_Amp结点失败：" << filePathIn;
         return -2;
    }
    //给定电流信号
    domparser.readXml(domNode, ao_weld_Amp);

    domNode = domparser.findSubNode(domNode_f, "ai_weld_voltageMes", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取ai_weld_voltageMes结点失败：" << filePathIn;
         return -2;
    }
    //焊接电压信号（反馈)
    domparser.readXml(domNode, ai_weld_voltageMes);

    domNode = domparser.findSubNode(domNode_f, "ratio_ao_weld_voltage", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取ratio_ao_weld_voltage结点失败：" << filePathIn;
         return -2;
    }
    domparser.readXml(domNode, ratio_ao_weld_voltage);

    domNode = domparser.findSubNode(domNode_f, "ratio_ao_weld_Amp", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取ratio_ao_weld_Amp结点失败：" << filePathIn;
         return -2;
    }
    domparser.readXml(domNode, ratio_ao_weld_Amp);

    domNode = domparser.findSubNode(domNode_f, "ratio_ai_weld_voltageMes", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取ratio_ai_weld_voltageMes结点失败：" << filePathIn;
         return -2;
    }
    domparser.readXml(domNode, ratio_ai_weld_voltageMes);

    domNode = domparser.findSubNode(domNode_f, "ratio_ai_weld_IrealMes", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取ratio_ai_weld_IrealMes结点失败：" << filePathIn;
         return -2;
    }
    domparser.readXml(domNode, ratio_ai_weld_IrealMes);

    domNode = domparser.findSubNode(domNode_f, "minimum_ao_weld_voltage", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取minimum_ao_weld_voltage结点失败：" << filePathIn;
         return -2;
    }
    domparser.readXml(domNode, minimum_ao_weld_voltage);

    domNode = domparser.findSubNode(domNode_f, "minimum_ao_weld_Amp", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取minimum_ao_weld_Amp结点失败：" << filePathIn;
         return -2;
    }
    domparser.readXml(domNode, minimum_ao_weld_Amp);

    domNode = domparser.findSubNode(domNode_f, "minimum_ai_weld_voltageMes", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取minimum_ai_weld_voltageMes结点失败：" << filePathIn;
         return -2;
    }
    domparser.readXml(domNode, minimum_ai_weld_voltageMes);

    domNode = domparser.findSubNode(domNode_f, "minimum_ai_weld_IrealMes", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取minimum_ai_weld_IrealMes结点失败：" << filePathIn;
         return -2;
    }
    domparser.readXml(domNode, minimum_ai_weld_IrealMes);

    domNode = domparser.findSubNode(domNode_f, "di_collision", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取di_collision结点失败：" << filePathIn;
         readComent+=",di_collision";
         return -2;
    }
    domparser.readXml(domNode, di_collision);

    domNode = domparser.findSubNode(domNode_f, "enable_collision_check", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取enable_collision_check结点失败：" << filePathIn;
         readComent+=",enable_collision_check";
         return -2;
    }
    domparser.readXml(domNode, enable_collision_check);

    domNode = domparser.findSubNode(domNode_f, "collision_normal_logic", ok );
    if( !ok )
    {
         qDebug() << "WeldStartInstructionLogic::readConfigFile ==== 读取collision_normal_logic结点失败：" << filePathIn;
         readComent+=",collision_normal_logic";
         return -2;
    }
    domparser.readXml(domNode, collision_normal_logic);

    qDebug() << "do_weld_start:" << do_weld_start;
    qDebug() << "do_reverse_wirefeeding:" << do_reverse_wirefeeding;
    qDebug() << "di_weld_startSucceful:" << di_weld_startSucceful;
    qDebug() << "ai_weld_IrealMes:" << ai_weld_IrealMes;
    qDebug() << "do_positive_wirefeeding:" << do_positive_wirefeeding;
    qDebug() << "do_gas_detection:" << do_gas_detection;
    qDebug() << "di_find_position:" << di_find_position;
    qDebug() << "ao_weld_voltage:" << ao_weld_voltage;
    qDebug() << "ao_weld_Amp:" << ao_weld_Amp;

    domparser.closeXml();
    return 1;
}
int WeldStartInstructionLogic::readConfigFile(QString filePathIn,QString &readComent)
{
   readComent.clear();
   usingMutex.lock();
   if(1!=readDiDoSetting( filePathIn,readComent))
   {
       usingMutex.unlock();
       return -1;
   }
   if(1!=readWeldProperty( filePathIn,weldPropertyList,readComent))
   {
       usingMutex.unlock();
       return -2;
   }
   if(1!=readWeldCondition( filePathIn,weldConditionList,readComent))
   {
       usingMutex.unlock();
       return -3;
   }

   usingMutex.unlock();
   return 1;
}

int WeldStartInstructionLogic::readWeldSystemInfo(QString filePathIn,WeldSystemInfo &weldSystemInfo,
                                                  bool &isUseArcWeldModuleOut, QString &readComent)
{
    qDebug() << "开始获取弧焊系统信息";

    DomParser domparser;
    bool ok = domparser.openXml(filePathIn, QIODevice::ReadOnly);
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 配置文件打开失败：" << configFilePath;
        return -1;
    }

    QDomNode domNode = domparser.findSubNode(domparser.getRootDomElement(), "SystemInfo", ok );
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 读取WeldSystemInfo结点失败：" << configFilePath;
        return -2;
    }

    // 读取并赋值
    domparser.readXml(domparser.findSubNode(domNode, "arc_depletion_detection", ok ), weldSystemInfo.arcDepletionDetection);
    domparser.readXml(domparser.findSubNode(domNode, "gas_depletion_detection", ok ), weldSystemInfo.gasDepletionDetection);
    domparser.readXml(domparser.findSubNode(domNode, "weldwire_depletion_detection", ok ), weldSystemInfo.weldwireDepletionDetection);
    domparser.readXml(domparser.findSubNode(domNode, "soluble_apply_testing", ok ), weldSystemInfo.solubleApplyTesting);
    domparser.readXml(domparser.findSubNode(domNode, "power_failure_detection", ok ), weldSystemInfo.powerFailureDetection);
    domparser.readXml(domparser.findSubNode(domNode, "water_abnormal_detection", ok ), weldSystemInfo.waterAbnormalDetection);

    domparser.readXml(domparser.findSubNode(domNode, "to_open_action", ok ), weldSystemInfo.toOpenAction);
    domparser.readXml(domparser.findSubNode(domNode, "to_open_distance", ok ), weldSystemInfo.toOpenDistance);
    domparser.readXml(domparser.findSubNode(domNode, "to_open_speed", ok ), weldSystemInfo.toOpenSpeed);

    domparser.readXml(domparser.findSubNode(domNode, "scrape_up_arc", ok ), weldSystemInfo.scrapeUpArc);
    domparser.readXml(domparser.findSubNode(domNode, "scraping_distance", ok ), weldSystemInfo.scrapingDistance);
    domparser.readXml(domparser.findSubNode(domNode, "return_velocity_to_startPoint", ok ), weldSystemInfo.returnStartPointSpeed);
    domparser.readXml(domparser.findSubNode(domNode, "retry_count", ok ), weldSystemInfo.retryCount);

    domparser.readXml(domparser.findSubNode(domNode, "backArc", ok ), weldSystemInfo.backArc);
    domparser.readXml(domparser.findSubNode(domNode, "numberOf_re_arcs", ok ), weldSystemInfo.numberOfArcs);

    domparser.readXml(domparser.findSubNode(domNode, "default_weldspeed", ok ), weldSystemInfo.defaultWeldspeed);

    domparser.readXml(domparser.findSubNode(domNode, "welding_microadjustment", ok ), weldSystemInfo.welding_microadjustment);
    domparser.readXml(domparser.findSubNode(domNode, "useTPforwelding", ok ), weldSystemInfo.useTPforwelding);
    domparser.readXml(domparser.findSubNode(domNode, "remote_gas_cleaning", ok ), weldSystemInfo.remote_gas_cleaning);
    domparser.readXml(domparser.findSubNode(domNode, "remote_inching_wirefeed", ok ), weldSystemInfo.remote_inching_wirefeed);
    domparser.readXml(domparser.findSubNode(domNode, "gas_cleaning_key", ok ), weldSystemInfo.gas_cleaning_key);
    domparser.readXml(domparser.findSubNode(domNode, "gas_cleaning_time", ok ), weldSystemInfo.gas_cleaning_time);
    domparser.readXml(domparser.findSubNode(domNode, "arcStartDetectTime", ok ), weldSystemInfo.arcStartDetectTime);
    domparser.readXml(domparser.findSubNode(domNode, "arcStartMaxWaitTime", ok ), weldSystemInfo.arcStartMaxWaitTime);
    domparser.readXml(domparser.findSubNode(domNode, "arcEndDelayAlarmTime", ok ), weldSystemInfo.arcEndDelayAlarmTime);
    domparser.readXml(domparser.findSubNode(domNode, "gasEndDelayAlarmTime", ok ), weldSystemInfo.gasEndDelayAlarmTime);
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 读取WeldSystemInfo结点失败：" << configFilePath;
        return -3;
    }

    domNode = domparser.findSubNode(domparser.getRootDomElement(), "isUseArcWeldModule", ok );
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 读取isUseArcWeldModule结点失败：" << configFilePath;
        return -2;
    }
    domparser.readXml(domNode, isUseArcWeldModuleOut);

    domparser.closeXml();
    return 1;
}

int WeldStartInstructionLogic::writeWeldSystemInfo(QString filePathIn, WeldSystemInfo &configIn)
{
    qDebug() << "开始修改弧焊系统信息";
    DomParser domparser;
    bool ok = domparser.openXml(filePathIn, QIODevice::ReadWrite);
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 配置文件打开失败：" << configFilePath;
        return -1;
    }

    QDomNode domNode = domparser.findSubNode(domparser.getRootDomElement(), "SystemInfo", ok );
    if( !ok )
    {
        qDebug() << "WeldProperty::readConfigFile ==== 读取WeldSystemInfo结点失败：" << configFilePath;
    }

    // 读取并赋值
    domparser.writeXml(domparser.findSubNode(domNode, "arc_depletion_detection", ok ), configIn.arcDepletionDetection);
    domparser.writeXml(domparser.findSubNode(domNode, "gas_depletion_detection", ok ), configIn.gasDepletionDetection);
    domparser.writeXml(domparser.findSubNode(domNode, "weldwire_depletion_detection", ok ), configIn.weldwireDepletionDetection);
    domparser.writeXml(domparser.findSubNode(domNode, "soluble_apply_testing", ok ), configIn.solubleApplyTesting);
    domparser.writeXml(domparser.findSubNode(domNode, "power_failure_detection", ok ), configIn.powerFailureDetection);
    domparser.writeXml(domparser.findSubNode(domNode, "water_abnormal_detection", ok ), configIn.waterAbnormalDetection);

    domparser.writeXml(domparser.findSubNode(domNode, "to_open_action", ok ), configIn.toOpenAction);
    domparser.writeXml(domparser.findSubNode(domNode, "to_open_distance", ok ), configIn.toOpenDistance);
    domparser.writeXml(domparser.findSubNode(domNode, "to_open_speed", ok ), configIn.toOpenSpeed);

    domparser.writeXml(domparser.findSubNode(domNode, "scrape_up_arc", ok ), configIn.scrapeUpArc);
    domparser.writeXml(domparser.findSubNode(domNode, "scraping_distance", ok ), configIn.scrapingDistance);
    domparser.writeXml(domparser.findSubNode(domNode, "return_velocity_to_startPoint", ok ), configIn.returnStartPointSpeed);
    domparser.writeXml(domparser.findSubNode(domNode, "retry_count", ok ), configIn.retryCount);

    domparser.writeXml(domparser.findSubNode(domNode, "backArc", ok ), configIn.backArc);
    domparser.writeXml(domparser.findSubNode(domNode, "numberOf_re_arcs", ok ), configIn.numberOfArcs);

    domparser.writeXml(domparser.findSubNode(domNode, "default_weldspeed", ok ), configIn.defaultWeldspeed);

    domparser.writeXml(domparser.findSubNode(domNode, "welding_microadjustment", ok ), configIn.welding_microadjustment);
    domparser.writeXml(domparser.findSubNode(domNode, "useTPforwelding", ok ), configIn.useTPforwelding);
    domparser.writeXml(domparser.findSubNode(domNode, "remote_gas_cleaning", ok ), configIn.remote_gas_cleaning);
    domparser.writeXml(domparser.findSubNode(domNode, "remote_inching_wirefeed", ok ), configIn.remote_inching_wirefeed);
    domparser.writeXml(domparser.findSubNode(domNode, "gas_cleaning_key", ok ), configIn.gas_cleaning_key);
    domparser.writeXml(domparser.findSubNode(domNode, "gas_cleaning_time", ok ), configIn.gas_cleaning_time);
    domparser.writeXml(domparser.findSubNode(domNode, "arcStartDetectTime", ok ), configIn.arcStartDetectTime);
    domparser.writeXml(domparser.findSubNode(domNode, "arcStartMaxWaitTime", ok ), configIn.arcStartMaxWaitTime);
    domparser.writeXml(domparser.findSubNode(domNode, "arcEndDelayAlarmTime", ok ), configIn.arcEndDelayAlarmTime);
    domparser.writeXml(domparser.findSubNode(domNode, "gasEndDelayAlarmTime", ok ), configIn.gasEndDelayAlarmTime);
    if( !ok )
    {
        qDebug() << "WeldProperty ==== write WeldSystemInfo结点失败：" << configFilePath;
        return -3;
    }
    domparser.closeXml(true);
    return 1;
}

void WeldStartInstructionLogic::addMsg(int messageLevel, string componentName,
                                       string messageType, int messageCode, int robotId, int parameter1,
                                       int parameter2, int parameter3, int parameter4, QString message)
{
    Message tmpMsg;
    tmpMsg.MessageLevel = messageLevel;
    tmpMsg.componentClassName = componentName;
    tmpMsg.messageType = messageType;
    tmpMsg.robotId = robotId;
    tmpMsg.messageCode = messageCode;
   // tmpMsg.time = t1.tv_sec;


    QString infomationStr;

    switch(messageCode)
    {
    case 12508:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",焊枪碰撞传感器触发！")+message;
        break;
    }
    case 12507:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",弧焊工艺模块未启用！")+message;
        break;
    }
    case 12506:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",焊接属性编号不存在！")+message;
        break;
    }
    case 12505:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",焊接条件编号不存在！")+message;
        break;
    }
    case 12504:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",不支持的焊接参数")+message;
        break;
    }
    case 12503:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",电弧中断报警")+message;
    }
        break;
    case 12502:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",超时未起弧")+message;
    }
        break;
    case 12501:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",焊接参数文件weldSystem.xml读取失败,")+message;
    }
        break;
    case 12500:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",焊接参数文件weldConfig.xml读取失败,")+message;
    }
        break;



    default:
    {

    }
    }


    tmpMsg.MessageInformation = infomationStr.toStdString();

    // qDebug()<<"53444444444444444444444"<< tmpMsg.messageCode;
    MessageLog::getInstance()->addMessage(tmpMsg);
}
